// @ts-ignore
import { NativeModules, Platform } from 'react-native';

const LINKING_ERROR =
  `The package 'react-native-check-permissions' doesn't seem to be linked. Make sure: \n\n` +
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
  '- You rebuilt the app after installing the package\n' +
  '- You are not using Expo managed workflow\n';

const CheckPermissions = NativeModules.CheckPermissions
  ? NativeModules.CheckPermissions
  : new Proxy(
      {},
      {
        get() {
          throw new Error(LINKING_ERROR);
        },
      }
    );

export function openSettings(): Promise<Number> {
  return CheckPermissions.openSettings();
}

export function checkMicrophone(): Promise<Object> {
  return CheckPermissions.checkMicrophone();
}

export function requestMicrophone(): Promise<Object> {
  return CheckPermissions.requestMicrophone();
}

export function checkCalendar(): Promise<Object> {
  return CheckPermissions.checkCalendar();
}

export function requestCalendar(): Promise<Object> {
  return CheckPermissions.requestCalendar();
}

export function checkReadCalendar(): Promise<Object> {
  return CheckPermissions.checkCalendar();
}

export function requestReadCalendar(): Promise<Object> {
  return CheckPermissions.requestCalendar();
}

export function checkWriteCalendar(): Promise<Object> {
  return CheckPermissions.checkCalendar();
}

export function requestWriteCalendar(): Promise<Object> {
  return CheckPermissions.requestCalendar();
}

export function checkCamera(): Promise<Object> {
  return CheckPermissions.checkCamera();
}

export function requestCamera(): Promise<Object> {
  return CheckPermissions.requestCamera();
}

export function checkPhotoLibrary(): Promise<Object> {
  return CheckPermissions.checkPhotoLibrary();
}

export function requestPhotoLibrary(): Promise<Object> {
  return CheckPermissions.requestPhotoLibrary();
}

export function openLimitedPhotoLibraryPicker(): Promise<Object> {
  return CheckPermissions.openLimitedPhotoLibraryPicker();
}

export function requestPhotoLibraryAddOnly(): Promise<Object> {
  return CheckPermissions.requestPhotoLibraryAddOnly();
}

export function checkPhotoLibraryAddOnly(): Promise<Object> {
  return CheckPermissions.checkPhotoLibraryAddOnly();
}

export function checkMediaLibrary(): Promise<Object> {
  return CheckPermissions.checkMediaLibrary();
}

export function requestMediaLibrary(): Promise<Object> {
  return CheckPermissions.requestMediaLibrary();
}

export function checkCoreLocation(): Promise<Object> {
  return CheckPermissions.checkCoreLocation();
}

export function requestCoreLocation(): Promise<Object> {
  return CheckPermissions.requestCoreLocation();
}

export function checkBluetooth(): Promise<Object> {
  return CheckPermissions.checkBluetooth();
}

export function requestBluetooth(): Promise<Object> {
  return CheckPermissions.requestBluetooth();
}

export function multiply(a: number, b: number): Promise<number> {
  return CheckPermissions.multiply(a, b);
}
